﻿public class VOFactory {
	@Resource
	private VOConverter1 converter1;
	@Resource
	private VOConverter2 converter2;
	...
	
	private Map<Class, IVOConverter> converterMapper = new HashMap<Class, IVOConverter>();
	
	public VOFactory() {
		initializeConverterMapper();
	}
	
	private void initializeConverterMapper() {
		converterMapper.put(VO1.class, converter1);
		converterMapper.put(VO2.class, converter2);
		...
	}
	
	public IVO getVO(Class<? extends IVO> resultType, VOSourceData source) {
		IVOConverter converter = findVOConverter(resultType);
		return converter.convert(source);
	}
	
	private findVOConverter(Class<? extends IVO> returnType) {
		return converterMapper.get(returnType);
	}
}

public interface IVO extends Serializable {}
public class VO1 implements IVO {...}
public class VO2 implements IVO {...}
public class VO3 implements IVO {...}

//generic param entity for all vo conversion
class VOSourceData extends HashMap<String, Object> {
	...//(code to enhance HashMap feature)
}

public interface IVOConverter<T extends IVO> {
	T convert(VOSourceData source);
}

@SourceDataList({"listBU", "betsOfToday", "listCategories"})
class VOConverter1 implements IVOConverter<VO1> {
	@Override
	public VO1 convert(VOSourceData source) {
		VO1 ret = new VO1();
		....
		return ret;
	}
}

@SourceDataList({"listPTs", "listCategories", "events", "user"})
class VOConverter2 implements IVOConverter<VO2> {
	@Override
	public VO2 convert(VOSourceData source) {
		VO2 ret = new VO2();
		....
		return ret;
	}
}